<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<%@page import="com.webside.points.wechat.Wechat"%>
<%
	 //正常跳转
	String code = (String)request.getParameter("code");
  
	String openId = null;
	
	if(code != null){
		Wechat.getOpenId(code,request,response);
	}
	
	if(openId == null){
		openId = (String)request.getSession().getAttribute("openId");
	}
	//如果从其他界面返回时，code已经失效，需要重新请求一次
	
	if(openId == null){
	   response.sendRedirect("../wechat/getWeChatCode");
	   return;
	}  
	
 %> 
<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
  <meta name="keywords" content="" />
  <meta name="description" content="" />
  <link rel="stylesheet" href="../css/amazeui.min.css">
  <link rel="stylesheet" href="../css/wap.css">
  <title>抢答记录列表</title>
    <style>
		a{color:#757575;}
    </style>
	<script src="../js/jquery.min.js"></script>
	  <script type="text/javascript" src="../js/timeago.js"></script>
	 <script type="text/javascript"
	src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
		<script src="../js/jssdk.js"></script>
		<link rel="stylesheet" href="../css/dropload.css">
	<script src="../js/dropload.min.js"></script>
</head>
<script type="text/javascript">
	$(function(){
		//时间转换为简单的文字
		
		$(".timeago").each(function(){
			var id = $(this).attr("id");
			var time = timeago(id);
			$(this).text(time);
		})
		
		
		$(function(){
			// 页数
			var page = 0;
			// 每页展示多少个
			var size = 10;
			var openId = $("#openId").val();
			// dropload
			$('.content').dropload({
				scrollArea : window,
				loadDownFn : function(me){
					page++;
					// 拼接HTML
					var result = '';
					$.ajax({
						type: 'post',
						url: '../answer/findAnswerRecord?page='+page+"&size="+size+"&openId="+openId,
						dataType: 'json',
						success: function(data){
							if(data!=null){
								var arrLen = data.length;
								//alert(page);
								if(arrLen > 0){
									for(var i=0; i<arrLen; i++){
										//判断是否停用
										if(data[i].status==1){
											result +=   '<li class="am-g am-list-item-desced pet_list_one_block">'
												+' <a href="${ctx }/issue/findById?issueId='+data[i].id+'&openId=&mark=answer" class="issue">'
												+'<div class="pet_list_one_info">'
													+'<div class="pet_list_one_info_l">'
														+'<div class="pet_list_one_info_ico"><img src="'+data[i].userEntity.headUrl+'" alt=""></div>'
														+'<div class="pet_list_one_info_name">'+data[i].userEntity.wechatId+'</div>'
													+'</div>'
													+' <div class="pet_list_one_info_r">'
													+' <div class="pet_list_tag"><span class="timeago">'+timeago(data[i].createDateFormat)+'</span></div>'
													+'</div>'
												+'</div>'
												+'<div class=" am-list-main">'
													+'<h3 class="am-list-item-hd pet_list_one_bt" style="color: #222;font-weight: bold;">'+data[i].issueContent+'</h3>'
												+'</div>'
												+'</a>'
											+'</li>';
										}
									}
														
								// 如果没有数据
								}else{
									// 锁定
									me.lock();
									// 无数据
									me.noData();
								}
							}else{
									// 锁定
									me.lock();
									// 无数据
									me.noData();
								}
							
							// 插入数据到页面，放到最后面
							$('.am-list').append(result);
							// 每次数据插入，必须重置
							me.resetload();
						},
						error: function(xhr, type){
							//alert('Ajax error!');
							// 即使加载出错，也得重置
							me.resetload();
						}
					});
				}
			});
		});
	})
</script>
<body style="background:#ececec">
<input type="hidden" value="<%=openId %>" id="openId">

  <div class="pet_mian" >
    <div class="pet_content pet_content_list">
      <div class="pet_article_like">
        <div class="pet_content_main pet_article_like_delete">
          <div data-am-widget="list_news" class="am-list-news am-list-news-default am-no-layout">
            <div class="am-list-news-bd content">
              <ul class="am-list">
              
			  </ul>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
   <script src="../js/amazeui.min.js"></script>
  <script src="../js/text-calculation.js"></script>
</body>
  </html>